/**
 * jims
 */
package com.jims.master.modules.oper.service;

import java.util.List;

import com.jims.master.common.service.TreeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.jims.master.common.persistence.Page;
import com.jims.master.common.service.CrudService;
import com.jims.master.modules.oper.entity.LabType;
import com.jims.master.modules.oper.dao.LabTypeDao;

/**
 * 检验类别Service
 * @author 赵宁
 * @version 2017-02-24
 */
@Service
@Transactional(readOnly = true)
public class LabTypeService extends TreeService<LabTypeDao, LabType> {

    @Autowired
    private LabTypeDao labTypeDao;

	public LabType get(String id) {
		return super.get(id);
	}
	
	public List<LabType> findList(LabType labType) {
		return super.findList(labType);
	}
	
	public Page<LabType> findPage(Page<LabType> page, LabType labType) {
		return super.findPage(page, labType);
	}

	/**
	 * 保存（修改）信息
	 * @param labType
	 * @return
	 * @author 赵宁
	 */
	@Transactional(readOnly = false)
	public int save(LabType labType) {
        if(labType.getParent()!=null && !"0".equals(labType.getParent().getId()) && !"".equals(labType.getParent().getId())){
			 labType.setLevel("2");
		}else{
			 labType.setLevel("1");
		}
		return super.save(labType);
	}
	
	@Transactional(readOnly = false)
	public int delete(LabType labType) {
		return super.delete(labType);
	}

    /**
     * 根据检验项目id查找其诊疗项目集合
     * @param id
     * @return
     * @Author 陈晓阳
     */
    public List<LabType> queryBylabTypeId(String id) {
        return labTypeDao.queryBylabTypeId(id);
    }
}